

; -----------------------------------------------------------------
;	Read from RTC
;		in:		R16 - address
;		out:	R16 - data

SPI_read:	
			out		SPDR, R16	; start transfer
			
wait_spi:	
			sbis	SPSR, SPIF
			rjmp	wait_spi
			in		R16, SPDR		
			
			ret


; -----------------------------------------------------------------
;	Send byte to RTC
;		in:		R16 
;		

rtc_send:

			out		SPDR, R16				; start transfer
			
rs_wait_spi:	
			sbis	SPSR, SPIF
			rjmp	rs_wait_spi
			
			in		R16, SPDR
			ret


; -----------------------------------------------------------------
;	Send byte to RTC
;		in:		R16 - address
;				R17 - data 
;		
rtc_write:
			rcall	rtc_send
			mov		R16, R17
			rcall	rtc_send
			sbi		PORT_SPI, RTC_SEL		; CS <- 1
			ret


; -----------------------------------------------------------------
;	Out byte to UART
;		in:		R16 - data
;		

SER_out:
			sbis	UCSRA, UDRE
			rjmp	SER_out
			out		UDR, R16
			ret


; -----------------------------------------------------------------
;	Make dump of RTC to UART
;		in:		
;		

RTC_dump:

			cbi		PORT_SPI, RTC_SEL		; CS <- 0





			sbi		PORT_SPI, RTC_SEL		; CS <- 0

			ret
